// server.js
require('dotenv').config();
const express = require('express');
const cors = require('cors');

const app = express();
app.use(cors())
app.use(express.json());

// 模拟数据库数据
const mockData = [
  { id: 1, content: '全栈开发' },
  { id: 2, content: 'Vue3+Node.js' }
];

// API端点
app.get('/demo/api/posts', (req, res) => {
  res.json({
    status: 'success',
    data: mockData,
    timestamp: Date.now()
  });
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`✅ 后端运行在：http://localhost:${PORT}`);
});
